Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Click the button to check if the ul element with id="myList" is the same as the document's first ul element. If so, add a color to its first child.</p> <button onclick="myFunction()">Try it</button> <ul id="myList"><li>Coffee</li><li>Tea</li></ul> <script> function myFunction() { var item1 = document.getElementById("myList"); var item2 = document.getElementsByTagName("UL")[0]; if (item1 === item2) { alert("THEY ARE THE SAME!!"); } else { alert("They are not the same."); } } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_node_issamenode2 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:28:45 GMT --> </html>
Result:
Try it Yourself - © w3schools.com